package exception;

/**
 * java异常处理机智
 * java中所有的异常的顶级超类:Throwable
 * Throwable
 */
public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了");
        try {
            //String line = null;
            //String line1 = "";
            String line = "abc";
            System.out.println(line.length());
            System.out.println(line.charAt(0));
            System.out.println(Integer.parseInt(line));
//        }catch (NullPointerException e){
//            System.out.println("出现了空指针并处理了");
//        }catch (StringIndexOutOfBoundsException e) {
//            System.out.println("出现了字符串下标越界并处理了");

        }catch (NullPointerException|StringIndexOutOfBoundsException e){
            System.out.println("空指针或下标越界的统一处理");
        }catch (Exception e){
            System.out.println("反正就是出了个错!");
        }

        System.out.println("程序结束了");
    }
}
